// internal/domain/batch.go
package domain

import (
	"context"
	"time"
)

// BatchService 批量操作服务接口
type BatchService interface {
	// 批量虚拟机操作
	BatchStartVMs(ctx context.Context, connID string, vmNames []string) (*BatchResult, error)
	BatchStopVMs(ctx context.Context, connID string, vmNames []string, force bool) (*BatchResult, error)
	BatchRebootVMs(ctx context.Context, connID string, vmNames []string) (*BatchResult, error)
	BatchDeleteVMs(ctx context.Context, connID string, vmNames []string, removeStorage bool) (*BatchResult, error)

	// 批量快照操作
	BatchCreateSnapshots(ctx context.Context, connID string, vmNames []string, config *SnapshotConfig) (*BatchResult, error)
	BatchDeleteSnapshots(ctx context.Context, connID string, operations []SnapshotOperation) (*BatchResult, error)

	// 批量配置更新
	BatchUpdateVMs(ctx context.Context, connID string, updates []VMUpdate) (*BatchResult, error)

	// 获取批量操作状态
	GetBatchStatus(ctx context.Context, batchID string) (*BatchStatus, error)
}

// BatchResult 批量操作结果
type BatchResult struct {
	BatchID    string            `json:"batch_id"`
	Total      int               `json:"total"`
	Successful int               `json:"successful"`
	Failed     int               `json:"failed"`
	Results    []OperationResult `json:"results"`
	StartTime  time.Time         `json:"start_time"`
	EndTime    time.Time         `json:"end_time"`
	Duration   time.Duration     `json:"duration"`
}

// OperationResult 单个操作结果
type OperationResult struct {
	Target  string `json:"target"` // VM 名称或其他目标
	Success bool   `json:"success"`
	Error   string `json:"error,omitempty"`
}

// BatchStatus 批量操作状态
type BatchStatus struct {
	BatchID  string       `json:"batch_id"`
	Status   string       `json:"status"` // running, completed, failed
	Progress float64      `json:"progress"`
	Results  *BatchResult `json:"results,omitempty"`
}

// VMUpdate 虚拟机更新操作
type VMUpdate struct {
	VMName string    `json:"vm_name"`
	Config *VMConfig `json:"config"`
}

// SnapshotOperation 快照操作
type SnapshotOperation struct {
	VMName       string `json:"vm_name"`
	SnapshotName string `json:"snapshot_name"`
}
